﻿<?xml version="1.0" encoding="utf-8" ?>
<content>
	<mainContent>
		<![CDATA[
		<h2>Registering Scripts and Styles <span>DNAide.Web.UI.Scripts / Styles</span></h2>
		<h3>Registering JavaScript</h3>
		<p><strong>DNAide.Web.UI.Scripts.ScriptAide</strong> has a series of helper methods that improve on the default ASP.NET Page.ReisterClientScriptBlock functionality. If you use Page.RegisterClientScriptBlock, you will know that all JavaScript is registered immediately after the WebForm's &lt;form runat="server"&gt; tag. Using ScriptAide, you can specify that scripts are registered in your WebForm's &lt;head&gt; tag or in any other location you specify.</p>
			
		<p><strong>Registering in the &lt;head&gt;</strong>:</p>
		<p>For this to work, you will need to have <strong>runat="server"</strong> in the &lt;head&gt; of your aspx / master file.</p>
		
		<pre class="csharpcode">
<span class="rem">// Register include</span>
ScriptAide.CurrentContext.RegisterInclude(<span class="str">"MyScripts"</span>, <span class="str">"~/js/my-scripts.js"</span>);
 
<span class="rem">// Register script block</span>
ScriptAide.CurrentContext.RegisterBlock(<span class="str">"SayHello"</span>, <span class="str">"alert('Hello!');"</span>, <span class="kwrd">true</span>);</pre>

		<p><strong>Registering in another location</strong>:</p>
		<p>To register in another location, create a <strong>PlaceHolder</strong> in your WebForm that will act as the register location. In your codebehind, you then specify the CustomRegisterControl in ScriptAide</p>
		
		<pre class="csharpcode">
ScriptAide.CurrentContext.CustomRegisterControl = MyPlaceHolder;
ScriptAide.CurrentContext.RegisterInclude(<span class="str">"MyScripts"</span>, <span class="str">"~/js/my-scripts.js"</span>);</pre>
		
		<p>All scripts registered using ScriptAide will be registered at the <strong>MyPlaceHolder</strong> location.</p>
		
		<p><strong>Registering with a conditional</strong>:</p>
		<p>The following example will register a JavaScript include with the client side conditional for Internet Explorer 6 and below only.</p>
		
		<pre class="csharpcode">
ScriptAide.CurrentContext.RegisterInclude(<span class="str">"ie.js"</span>, <span class="str">"~/js/ie.js"</span>, <span class="str">"lte IE 6"</span>);</pre>
	
	
		<h3>Registering Styles</h3>
		<p>DNAide also includes a StyleAide which includes a series of register methods which work in a similar fashion to ScriptAide e.g.</p>
		
		<pre class="csharpcode">
StyleAide.CurrentContext.RegisterInclude(<span class="str">"Screen.css"</span>, <span class="str">"~/css/screen.css"</span>);

StyleAide.CurrentContext.RegisterInclude(<span class="str">"IE.css"</span>, <span class="str">"~/css/ie.css"</span>, <span class="str">"screen"</span>, <span class="str">"lte IE 6"</span>);

StyleAide.CurrentContext.RegisterInclude(<span class="str">"IE7.css"</span>, <span class="str">"~/css/ie7.css"</span>, <span class="str">"screen"</span>, <span class="str">"IE 7"</span>);</pre>
			
	 
		]]>
	</mainContent>

	<secondaryContent>
		<![CDATA[
		]]>
	</secondaryContent>
</content>
